### must use go >= 1.18

TARGET_DIR=dist
APP=bilin-mock

# Go parameters
GOCMD=GO111MODULE=on go
GOBUILD=$(GOCMD) build
GODOWNLOAD=$(GOCMD) mod download

# DB
DB_SCHEMA_SOURCE=~/dber/biling-dber/migration/bilin-mock
DB_SCHEMA_TO=./internal/db/migration

env:
	echo "shell exec => gvm use go1.18beta1"

sch:
	ln -s $(DB_SCHEMA_SOURCE) $(DB_SCHEMA_TO)

sqlc:
	sqlc generate

dev:
	go run cmd/main.go


download:
	$(GODOWNLOAD)

build:
	rm -rf $(TARGET_DIR)
	mkdir -p $(TARGET_DIR)
	#cp conf/config.toml $(TARGET_DIR)/config.toml
	$(GOBUILD) -o $(TARGET_DIR)/$(APP) cmd/main.go

clean:
	rm -rf $(TARGET_DIR)

run:
	nohup $(TARGET_DIR)/$(APP) -c=$(TARGET_DIR)/config.toml 2>&1 > $(TARGET_DIR)/$(APP).log &

stop:
	pkill -f $(TARGET_DIR)/$(APP)